//
//  HEDoctorCommentCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/17.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEDoctorCommentCell.h"
#import "HDRatingStarView.h"

@interface HEDoctorCommentCell ()

@property (nonatomic, strong) UIImageView *userIconView;
@property (nonatomic, strong) UILabel *nameLb;
@property (nonatomic, strong) HDRatingStarView *startView;
@property (nonatomic, strong) UILabel *cotentLb;

@end

@implementation HEDoctorCommentCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
        
        self.qmui_borderPosition = QMUIViewBorderPositionBottom;
        self.qmui_borderWidth = 1;
        self.qmui_borderColor = CSplitLineColor;
    }
    return self;
}

- (void)initUI {
    
    UIView *warp = [UIView new];
    warp.backgroundColor = KWhiteColor;
    [self.contentView addSubview:warp];
    
    [warp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(0);
        make.left.equalTo(self.contentView).mas_offset(0);
        make.right.equalTo(self.contentView).mas_offset(0);
        make.height.mas_greaterThanOrEqualTo(95);
        make.bottom.equalTo(self.contentView).mas_offset(-10);
    }];
    
    // 头像
    _userIconView = [UIImageView new];
    _userIconView.image = IMAGE_NAMED(@"noImage");
    _userIconView.contentMode = UIViewContentModeScaleAspectFill;
    [warp addSubview:_userIconView];

    // 姓名
    _nameLb = [UILabel new];
    _nameLb.text = @"张三";
    _nameLb.font = DYFont(17);
    [warp addSubview:_nameLb];

    // 星星评分
    _startView = [[HDRatingStarView alloc] init];
    _startView.renderColor = KHexColor(@"F67605");
    _startView.defaultColor = KHexColor(@"CDCDCD");
    _startView.allowTouchToSelectScore = NO;
    _startView.score = 0;
    _startView.starWidth = 15;
    _startView.starImage = IMAGE_NAMED(@"rating_sel");
    [self.contentView addSubview:_startView];
    
   
    // 评论
    _cotentLb = [UILabel new];
    _cotentLb.text = @"cdscdscdscdscdscdscdscdscdscdscdscdscdscdscdscdscdscdscdscdscdscdscdscdscdscds";
    _cotentLb.font = DYFont(15);
    _cotentLb.numberOfLines = 0;
    [self.contentView addSubview:_cotentLb];
    
    [_userIconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(warp).mas_offset(15);
        make.left.equalTo(warp).mas_offset(15);
        make.width.height.mas_offset(72);
    }];
    [_userIconView hg_setAllCornerWithCornerRadius: 36];
 
    [_nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
       make.top.equalTo(_userIconView.mas_top);
       make.left.equalTo(_userIconView.mas_right).mas_offset(11);
    }];
    
    [_startView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_nameLb);
        make.left.equalTo(_nameLb.mas_right).mas_offset(10);
        make.right.equalTo(warp).mas_offset(-15);
        make.height.mas_offset(15);
    }];
    
    [_cotentLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_nameLb.mas_bottom).mas_offset(10);
        make.left.equalTo(_nameLb.mas_left);
        make.right.equalTo(warp).mas_offset(-15);
        make.bottom.equalTo(warp).mas_offset(-15);
    }];
}

-(void)refreshContent:(GDFiterCellModel *)fiterModel formModel:(GDFormModel *)formModel indexPath:(NSIndexPath *)indexPath {

    HEDoctorCommentModel *model = formModel.doc_commentList[indexPath.row];
    
    [_userIconView sd_setImageWithURL:[NSURL URLWithString: model.avatar] placeholderImage: IMAGE_NAMED(@"defualt_icon")];
    _nameLb.text = model.KName;
    _startView.score = model.score;
    _cotentLb.text = model.content;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
